const express =require('express')
const router=express.Router()
// 验证表单数据模块
const expressJoi=require('@escook/express-joi')
// 路由处理函数
const articleRuter=require('../router_handler/article')
// 导入验证的规则
const {add_article_schema}=require('../schema/article')
// 导入解析 formdata 格式表单数据的包
const multer = require('multer')
// 导入处理路径的核心模块
const path = require('path')
// 创建实例对象，并通过dest属性指定存放的路径
const upload = multer({ dest: path.join(__dirname,'../uploads') })
// 发布新文章
router.post('/add',upload.single('cover_img'),expressJoi(add_article_schema), articleRuter.addArticle)

module.exports=router